#include<bits/stdc++.h>
using namespace std;
struct car{
    int d;
    int v;
    int a;
};
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    int counting[t][2];
    for(int i = 0;i < t;i++){
        int n,m,l,v,ans = 0;
        cin >> n >> m >> l >> v;
        car a[n];
        bool cars[n] = {0};
        for(int j = 0;j < n;j++){
            cin >> a[j].d >> a[j].v >> a[j].a;
        }
        int p[m];
        bool camera[m] = {0};
        for(int j = 0;j < m;j++){
            cin >> p[j];
        }
        for(int k = 0;k < n;k++)
        {
            for(int x = 0;x < m;x++){
                if(p[x] < a[k].d)  continue;
                int vt = sqrt(a[k].v*a[k].v+a[k].a*(p[x] - a[k].d)*2);
                if(vt > v){
                    camera[x] = 1;
                    cars[k] = 1;
                }
            }
        }
        for(int j = 0;j < n;j++){
            if(cars[j])  ans++;
        }
        for(int j = 0;j < m;j++){
            if(camera[j])  m--;
        }

        counting[i][0] = ans;
        counting[i][1] = m;
        }
    for(int i = 0;i < t;i++)  cout << counting[i][0] << " " << counting[i][1] << endl;
    return 0;
}
